<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no"/>
    <title>提交订单</title>
    <link rel="stylesheet" type="text/css" href="../../css/common.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/api.css"/>
    <script src="../../template/js/jquery.js"></script>
	<script type="text/javascript" src="../../script/constants.js"></script>
	<script type="text/javascript" charset="UTF-8" src="../../script/naes.js"></script>
	<script src="../../script/api.js"></script>
    <style>
    	body{
    		display: -webkit-box;
	        -webkit-box-orient: vertical;
    	}
    	.roomHead {
    		margin: 0;
    		width: auto;
    		height:200px;
    		background-color: #339999;
    		color: #F7F6F6;
    	}
    	.room {
    		width: 90%;
    		height: 130px;
    		top: 0px;
			bottom: 0px;
			left: 0px;
			right: 0px;
			margin-left: auto;
			margin-right: auto;
    		background-color: #FFFFEE;

    	}
    	.roomTable {
    		width: 100%;
    	}

    	.dateTable td {
    	    font-size: 18px;
    		padding-left: 15px;
    		border-bottom: 1px solid #D8D8D8;
    	}

    	.dateTable tr {
    	    width: 100%;
    	}

    	.roomTable tr{
    		width: 100%;
    		height: 50px;
    		line-height: 50px;
    	}

    	.roomTable td {
    	    font-size: 18px;
    		padding-left: 15px;
    		border-bottom: 1px solid #D8D8D8;
    	}
    	.rmb {
    		background-color: #FFFFEE;
    		font-size: x-large;
    		font-weight:800;
    		color: #FF6600;
    		text-align: center;
    	}
    	.bookRoom {
	    	width:100%;
	    	height:100%;
    		background-color: #FF9900;
    		font-size: x-large;
    		color: #F7F6F6;
    	}
    	.addRoom input{
    		width:40px;
    		height:75%;
    		margin-left: 20px;
    		background-color: #FFFFEE;
    		border: 1px solid #6666FF;
    	}
    	.bzscf{
    		width:80%;
    		height:150px;
    		top: 0px;
			bottom: 0px;
			left: 0px;
			right: 0px;
			margin-left: auto;
			margin-right: auto;
    	}
    	.yxfj{
       		color:#000000;
       		margin-top:5px;
       		margin-left:3px;
       		width:30px;
       		height:20px;
       		line-height: 20px;
       		text-align: center;
       		font-size: 18px;
       }
       .noscroll,
		.noscroll body {
		    overflow: hidden;
		}
		.noscroll body {
		    position: relative;
		}
    	#bg{position: absolute;  top: 0%;  left: 0%;  width: 100%;background-color: black;  z-index:1001;  -moz-opacity: 0.7;  opacity:.70;  filter: alpha(opacity=70);}

    	.radio{
		    display: inline-block;
		    position: relative;
		    line-height: 18px;
		    margin-right: 10px;
		    cursor: pointer;
		}
		.radio input{
		    display: none;
		}
		.radio .radio-bg{
		    display: inline-block;
		    height: 18px;
		    width: 18px;
		    margin-right: 5px;
		    padding: 0;
		    background-color: #1e6887;
		    border-radius: 100%;
		    vertical-align: top;
		    box-shadow: 0 1px 15px rgba(0, 0, 0, 0.1) inset, 0 1px 4px rgba(0, 0, 0, 0.1) inset, 1px -1px 2px rgba(0, 0, 0, 0.1);
		    cursor: pointer;
		    transition: all 0.2s ease;
		}
		.radio .radio-on{
		    display: none;
		}
		.radio input:checked + span.radio-on{
		    width: 10px;
		    height: 10px;
		    position: absolute;
		    border-radius: 100%;
		    background: #FFFFFF;
		    top: 4px;
		    left: 4px;
		    box-shadow: 0 2px 5px 1px rgba(0, 0, 0, 0.3), 0 0 1px rgba(255, 255, 255, 0.4) inset;
		    background-image: linear-gradient(#ffffff 0, #e7e7e7 100%);
		    transform: scale(0, 0);
		    transition: all 0.2s ease;
		    transform: scale(1, 1);
		    display: inline-block;
		}
    </style>
</head>
<body>
<header id="statusBar">
        <div style="height:75px;background: #298cb4;display: table;width: 100%;">
           <div style="height:50px;margin-top: 25px;line-height: 50px;color: #ffffff;background: #1e6887;">
               <div style="z-index: 999;margin-left: 10px;position: absolute;" onclick="api.closeWin();">
	           返回
	           </div>
	           <div id="title" style="text-align: center;font-weight:bold;width: 100%;">
	           酒店预订
	           </div>
           </div>
        </div>
	</header>
	        <table style="width: 100%;" class="dateTable">
			  <tr>
   						<td style="width: 100px">预定时间</td>
	   					<td style="">
	   				        <input id="rzsj" type="date" readonly="true" style="color: #a2a3a2;"  min="" onchange="modifyStartTime()"/>
	   						<input id="amount" ype="text" value="共1晚" readonly="true" style="color: #a2a3a2;font-size: 14px;"/>
	   						<input id="tfsj" type="date" readonly="true" style="color: #a2a3a2;" min="" onchange="modifyEndTime()"/>
	   						</td>
   					</tr>
			</table>

			<table class="roomTable">
				<tbody>
					<tr>
						<td style="width: 100px;">已选房间</td>
						<td id="fjs" style="color: #a2a3a2;">

						</td>
					</tr>
					<tr>
						<td>预订人</td>
						<td><input id="ydr" type="text" value="请填写预订人姓名" style="color: #DDDDDD;"
							onfocus='if(this.value=="请填写预订人姓名"){this.value="";this.style.color="#A2A3A2";};'
							onblur='if(this.value==""){this.value="请填写预订人姓名";this.style.color="#DDDDDD";};'/>
						</td>
					</tr>
					<tr>
						<td>联系手机</td>
						<td><input id="lxdh" type="text" value="用于接收通知信息" style="color: #DDDDDD;"
							onfocus='if(this.value=="用于接收通知信息"){this.value="";this.style.color="#A2A3A2";};'
							onblur='if(this.value==""){this.value="用于接收通知信息";this.style.color="#DDDDDD";};' />
						</td>
					</tr>
				</tbody>
			</table>

			<div>
			    <div style="height: 50px;font-size: 18px;margin-left: 15px;color: #a2a3a2;">
			       选择开票信息
			    </div>
			    <div style="width: 100%;display: table;height: 50px;line-height: 50px;border-top: 1px solid #D8D8D8; ">
			       <div style="float: left;margin-left: 15px;font-size: 18px;" id="invoice">
			         不开票
			       </div>
			       <div style="float: right;margin-right: 10px;height: 25px;width: 55px;position: relative;top: 50%; transform: translateY(25%);" id="switch">

			       </div>
			    </div>
			   <div id="invoice_info" style="width: 100%;height: 50px;border-bottom: 1px solid #D8D8D8;border-top: 1px solid #D8D8D8;display: none;" onclick="selectInfo();">
			       <div style="float: left;width: 80%;margin-left: 5%;height: 50px;margin-top: 5px;">
			            <div style="height: 20px;line-height: 20px;" id="company">

			            </div>
			            <div style="height: 20px;line-height: 20px;" id="taxcode">

			            </div>
			            <input type="hidden" id="invoice_id" />
			       </div>
			        <div style="float: right;margin-right: 10px;position: relative;top: 50%; transform: translateY(-50%);width: 25px;height: 25px;">
			         <img style="width: 100%;height: 100%;" src="../../image/timg.png"/>
			       </div>
			   </div>
			</div>
			<table class="ftr" id="ftr" style="width: 100%;height: 60px;bottom: 0;position: absolute;" >
				<tbody>
					<tr>
						<td class="rmb" style="width: 50%;"><span style="font-size: large;color: #FF6600;">&yen;</span><span id="je"></span></td>
						<td style="width: 50%;padding: 0;margin: 0;left: 0;"><input type="button" value="提交订单" class="bookRoom" onclick="bookRoomAction()"/></td>
					</tr>
				</tbody>
			</table>
			<div id="invoice_box" style="display:none;width: 90%;position: absolute;top: 30%;left: 50%;transform: translateX(-50%);background: #ffffff;border-radius: 10px;padding-top: 10px;padding-bottom: 10px;">

			   </div>
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../resource/jquery-1.js"></script>
<script type="text/javascript">
	var num;
	var roomIdArr;
	var je;
	var orderid;
	var height;
	var xzdate = $api.getStorage("xzdate");
	var InvoiceList;
	var infolist = "";
	var merid = "";
	var flag=1;  //用于判断酒店是否有建筑结构
	apiready = function(){
		merid = api.pageParam.merid;
		var title = api.pageParam.jstitle;
		roomIdArr = api.pageParam.roomIdArr;
		flag = api.pageParam.flag;

		num = roomIdArr.length;
		height = document.documentElement.clientHeight;
		var price = 0;
		var html = "";
		je = parseInt(price);
		var fjs = document.getElementById('fjs');

   if(flag==0){
		 var	num = api.pageParam.num;
		var price = api.pageParam.price;
			 for(var i=0;i<roomIdArr.length;i++){
					$api.append(fjs, roomIdArr[i]);
					$api.append(fjs, "&nbsp&nbsp&nbsp&nbsp"+num+"间");
			 }

			je = num*price;

	 }else {
		 for(var i=0;i<roomIdArr.length;i++){
			 var temp = parseFloat(roomIdArr[i][3]);
			 je += temp;
			 if(i!=0 && i%3==0){
				 $api.append(fjs, '</br><span class="yxfj">'+roomIdArr[i][2]+'</span>');
			 }else{
				 $api.append(fjs, '<span class="yxfj">'+roomIdArr[i][2]+'</span>');
			 }
		 }
	 }

		$("#fjsValue").val(num);
		$("#je").text(je);
		var startTime = api.pageParam.startTime;
		var endTime = api.pageParam.endTime;
		var today = getNowFormatDate(startTime,0);
		var temo = getNowFormatDate(endTime,0);
		//alert(dateArr[0]);
		var rzsj = document.getElementById('rzsj');
		var tfsj = document.getElementById('tfsj');

		$('#rzsj').val(today);
		$('#tfsj').val(temo);
		$('#title').text(title);
		var callback = function(ret, err){
               if(ret){
                   InvoiceList = ret.xlist;
                   if(ret.xlist.length > 0){
                      var html = "";
                      infolist += "[";
                      for(var i=0; i < ret.xlist.length; i++){
                         if($api.getStorage("defid") == ret.xlist[i].ID){
                            $("#company").html(ret.xlist[i].USERNAME);
                            $("#taxcode").html(ret.xlist[i].TAXCODE);
                            $("#invoice_id").html(ret.xlist[i].ID);
                         }
                         infolist += "{'id':'"+ret.xlist[i].ID+"','taxcode':'"+ret.xlist[i].TAXCODE+"','text':'"+ret.xlist[i].USERNAME+"','status':'normal'},"
                      }
                      infolist = infolist.substring(0,infolist.length-1);
                      infolist += "]";
                      if($("#invoice_id").html() == "" ){
	                        $("#company").html(ret.xlist[0].USERNAME);
	                        $("#taxcode").html(ret.xlist[0].TAXCODE);
	                        $("#invoice_id").html(ret.xlist[0].ID);
                      }
                   }
               }else{
                   alert(JSON.stringify(err));
               }
		    }
	    // var content = {"openId":$api.getStorage("dl_phone")};
			  var content = {"openId":15680030061};
	    apiAjax(JSON.stringify(content),url.hqkpxx,callback);

		var os = $api.offset($api.dom('#switch'));
        var h = $("#switch").height();
        var w = $("#switch").width();
		var switchBtn = api.require('UISwitchButton');
			switchBtn.open({
			    id:'switch',
			    state:false,
			    rect: {
			      x: os.l,
			      y: os.t,
			      w: w,
			      h: h
			    },
			    styles:{
			       bgCorner:15,
			       active:'#71C671' ,
			       inActive:'#CFCFCF',
			       thumb:{
			          active:'#ffffff' ,
			          inActive:'#A1A1A1' ,
			          size:23,
			          corner:12
			       }
			    },
			    fixedOn: '',
			    fixed: false
			}, function(ret) {
			    //console.log(JSON.stringify(ret));
			    if(ret.state){
			       $("#invoice").html("开票");
			       if(InvoiceList.length > 0){
			          $("#invoice_info").show();
			       }else{
			          api.openWin({
	                      name: 'tjxx',
	                      url: '../yst/tjxx.html'
                      });
			       }
			    }else{
			       $("#invoice").html("不开票");
			       $("#invoice_info").hide();
			    }
			});
	};

	window.onresize = function () {

    var h = $(window).height();
    //console.log(h+','+window.screen.availHeight)
    var u = navigator.userAgent;
    if (u.indexOf('Android') > -1 || u.indexOf('Linux') > -1) {
        if(h <= window.screen.availHeight/2){
            $('#ftr').css({'position':'absolute','bottom':'0'});
        }else{
            $('#ftr').css({'position':'static','margin-top':'180px'});

        }
    }

}
$('input').on('focus',function(){

     $('#toNav').hide();

})

$('input').on('blur',function(){

     $('#toNav').show();

})

	function selectInfo(){
	  var UIMultiSelector = api.require('UIMultiSelector');
		 UIMultiSelector.open({
		     rect: {
		         h: 295
		     },
		     text: {
		         title: '开票信息',
		         leftBtn: '取消',
		         rightBtn: '确认',
		         selectAll: 'ALL'
		     },
		     max: 0,
		     singleSelection: true,
		     styles: {
		         bg: '#fff',
		         mask: 'rgba(0,0,0,0.5)',
		         title: {
		             bg: '#fff',
		             color: '#27a8fa',
		             size: 16,
		             h: 44
		         },
		         leftButton: {
		             bg: '#fff',
		             w: 80,
		             h: 35,
		             marginT: 5,
		             marginL: 8,
		             color: '#FF6347',
		             size: 14
		         },
		         rightButton: {
		             bg: '#fff',
		             w: 80,
		             h: 35,
		             marginT: 5,
		             marginR: 8,
		             color: '#32CD32',
		             size: 14
		         },
		         item: {
		             h: 50,
		             bg: '#FAFAFA',
		             bgActive: '#27a8fa',
		             bgHighlight: '#27a8fa',
		             color: '#8d8d8d',
		             active: '#fff',
		             highlight: '#fff',
		             size: 16,
		             lineColor: '#EBEBEB',
		             textAlign: 'center'
		         },
			     icon: {                            //（可选项）JSON 类型；每个选项的状态图标样式，若不传则不显示选中的状态图标
			        w: 0,                         //（可选项）数字类型；图标的高度；默认：20
			        h: 0,                         //（可选项）数字类型；图标的高度；默认：w
			        marginT: 11,                   //（可选项）数字类型；图标的上边距；默认：(item.h - h) / 2
			        marginH: 8,                    //（可选项）数字类型；图标的横向边距，与 align 的对齐方向相关；默认：8
			        bg: '#fff',                    //（可选项）字符串类型；图标未选中时的背景，支持 rgb、rgba、#、img；默认：rgba(0,0,0,0)
			        bgActive: '#fff',              //（可选项）字符串类型；已选中图标的背景，支持 rgb、rgba、#、img；默认：bg
			        bgHighlight: '#fff',           //（可选项）字符串类型；选项的高亮背景，支持 rgb、rgba、#、img；默认：bg
			        align: 'left'                  //（可选项）字符串类型；图标相对与选项的对齐方式：'left|right'；默认：left
			     }
		     },
		     animation: true,
		     items:  eval("("+infolist+")")
		 }, function(ret, err) {
		     if (ret) {
		         if(ret.eventType == "clickLeft"){
		            UIMultiSelector.hide();
		         }else if(ret.eventType == "clickRight"){
		             $("#company").html(ret.items[0].text);
		             $("#taxcode").html(ret.items[0].taxcode);
		             $("#invoice_id").val(ret.items[0].id);
		            UIMultiSelector.hide();
		         }
		     } else {
		         alert(JSON.stringify(err));
		     }
		 });


	}

	function getNowFormatDate(date , addDayCount) {

   		var now = new Date(date);
		now.setDate(now.getDate()+addDayCount);
		//格式化日，如果小于9，前面补0
		var day = ("0" + now.getDate()).slice(-2);
		var mday =  ("0" + now.getDate()).slice(-2);
		var month = ("0" + (now.getMonth() + 1)).slice(-2);
		//拼装完整日期格式
		var date = now.getFullYear()+"-"+(month)+"-"+(day) ;
		return date;

	}
	function bookRoomAction(){
		var lxdhMsg = $("#lxdh").val();
		var ydrMsg = $("#ydr").val();
		var rzsjMsg = $("#rzsj").val();

		var tfsjMsg = $("#tfsj").val();
		if((rzsjMsg+"").length<1){
			alert("请输入时间");
			return false;
		}
		if((tfsjMsg+"").length<1){
			alert("请输入时间");
			return false;
		}
		if(ydrMsg=='请填写预订人姓名'){
			alert("请输入预订人姓名");
			return false;
		}

		if(/^\d*$/g.test(lxdhMsg)){

			if((lxdhMsg+"").length!=11){
				alert("您输入的号码长度有误");
				return false;
			}
		}else{
			alert("请输入正确的手机号码格式");
			return false;
		}
		var dl_phone = $api.getStorage("dl_phone");
		if(dl_phone==null||dl_phone==''||typeof(dl_phone)==undefined||dl_phone=='undefined'){
			api.alert({
				msg:'请登录'
	        },function(ret,err){
	        	api.openWin({
		            name: 'login',
		            url: '../login.html'
		            //url:'html/jskp/jskp.html'
	            });
	        });

		}else{
			api.toast({
	           msg:'数据提交中...'
           });
           var rzsj = $('#rzsj').val();
		var tfsj = $('#tfsj').val();
		var ydr = $('#ydr').val();
		var lxdh = $('#lxdh').val();
		var num = roomIdArr.length;
		var money = $('#je').text();
		var roomTypeId = api.pageParam.roomTypeId;
		var width = document.documentElement.clientWidth;

		//alert(roomIdArr.length);
		var roomInfoArr =  roomIdArr.join(";");
		var jdid = $api.getStorage("jdid");
//		api.ajax({
//	        url:"http://wechat.scjinsui.com/weixin/jdyd/order.do",
//	       	method: 'post',
//	       	cache: 'false',
//	        timeout: 30,
//	        dataType: 'json',
//			data: {
//				values: {
//					roomInfoArr:roomInfoArr,
//	           		rzsj:rzsj,
//	           		tfsj:tfsj,
//	           		num:num,
//	           		ydr:ydr,
//	           		lxdh:lxdh,
//	           		dlzh:dl_phone,
//	           		je:money,
//	           		jdid:jdid
//				}
//			}
//      },function(ret,err){
        var callback = function(ret, err){
            console.log(JSON.stringify(ret));
        	var data = eval("("+ret.list+")");
        	//alert(JSON.stringify(data));
        	orderid = data[0].NO;

//      	for(var i=0;i<data.length;i++){
//      		var status = data[i].STATUS;
//      		if(status == "0"){
//      			alert("您有未支付订单，完成支付后即可再次预订！");
//      			api.openWin({
//	                name: 'list',
//	                url: './my_order.html',
//	                pageParam:{
//	                	num:'1'
//	                }
//              });
//      		return false;
//      		}
//      	}
console.log(orderid);
        	if(orderid==null){
        		alert("对不起！该房间已被预订！");
        		return false;
        	}
//        	alert("订单提交成功！");
//      	var hh = document.body.scrollHeight;
//			if(api.systemType == "android"){
//			    $api.setStorage("frame","paymethod");
//			    $('html').addClass('noscroll');
//			 }else{
//			    $("body").on("touchmove",function(event){
//				event.preventDefault;
//				}, false)
//			 }
//			 document.getElementById("bg").style.height = hh+"px";
//			 document.getElementById("bg").style.display="";
	            	api.openFrame({
					    name: 'ylzf',
					    url: './paymethod.html',
					    rect: {
						    x:0,
						    y:height*0.6,
						    w:width,
						    h:height*0.4
					    },
					    pageParam: {


			           		dlzh:dl_phone,
			           		je:je

					    }
				    });
	        }
	    var parameter = {
					roomInfoArr:roomInfoArr,
	           		rzsj:rzsj,
	           		tfsj:tfsj,
	           		num:num,
	           		ydr:ydr,
	           		lxdh:lxdh,
	           		dlzh:dl_phone,
	           		je:money,
	           		jdid:jdid};
	    apiAjax(JSON.stringify(parameter),url.jdorder,callback);

		return false;
	}

		/**
		 *allspmc : allspmc,//商品名称
		       orderid : orderid,//订单号
		       dzObj : dzObj,//所有地址
		        bmc : bmc,//开票单位还是个人
		        seli : seli,//第几个地址
		        amc : amc1,//收货人姓名
	   	  		adh : adh1,//收货人电话
	   	  		adz : adz1,//收货人地址
	   	  		bsh :$("#kp_sh").val(),//税号
		    	bdzdh :$("#kp_dzdh").val(),//开票单位地址电话
		    	bkhh :$("#kp_khh").val(),//单位开户行账号
		    	bfplx :$("#kp_fplx").val(),//发票类型
		    	zje : allPrice1//金额
		 */



	}
	function uPay(){

     var allPrice1 = je;

     var width = document.documentElement.clientWidth;
	 var height = document.documentElement.clientHeight;
	 var hh = document.body.scrollHeight;
	 if(api.systemType == "android"){
	    $api.setStorage("frame","paymethod");
	    $('html').addClass('noscroll');
	 }else{
	    $("body").on("touchmove",function(event){
		event.preventDefault;
		}, false)
	 }
	 //alert(orderid)
//	 document.getElementById("bg").style.height = hh+"px";
//	 document.getElementById("bg").style.display="";
	 $api.setStorage("frame","");
	 $api.setStorage("upay","unionpay");
		api.openFrame({
		    name: 'jdylzf',
		    url: './unionpay.html',
		    rect: {
			    x:0,
			    y:height*0.4,
			    w:width,
			    h:height*0.6
		    },
		    pageParam: {

		       orderid : orderid,
		    	zje : allPrice1,
		    	merid : merid
		    }
	    });
	    //alert(orderid);
	    }
	    function funcGoto(){
        if(api.systemType == "android"){
            $('html').removeClass('noscroll');
        }else{
            $("body").off("touchmove");
        }
	     //document.getElementById("bg").style.display="none";
	    }

	    function funcGoto1(){
        if(api.systemType == "android"){
            $('html').removeClass('noscroll');
        }else{
            $("body").off("touchmove");
        }
	     document.getElementById("bg").style.display="none";
	     api.closeToWin({
	     name: 'root'
         });
	    }


	    function show(){
	     $("#loadingToast").show();
	    }

	    function hide(){
	     $("#loadingToast").hide();
	    }
	function closeTj(){
	  api.closeFrame({
	   name:'zffs'
      });
	  api.closeWin({});
	}


	 function modifyStartTime(){
          	var st = $("#rzsj").val();
          	var startTime = getNowFormatDate(st,0);
          	var endTime = getNowFormatDate(st,1);
 			$("#tfsj").val(endTime);
 			var et = document.getElementById('tfsj');
 			$api.attr(et, 'min', endTime);
          }

          function modifyEndTime(){
          	var startDate = $("#rzsj").val();
          	var endDate = $("#tfsj").val();
          	var ddate = getDays(startDate,endDate);
          	$("#amount").val("共"+ddate+"晚");
          }

          function getDays(date1 , date2){
            var date1Str = date1.split("-");//将日期字符串分隔为数组,数组元素分别为年.月.日
            //根据年 . 月 . 日的值创建Date对象
            var date1Obj = new Date(date1Str[0],(date1Str[1]-1),date1Str[2]);
            var date2Str = date2.split("-");
            var date2Obj = new Date(date2Str[0],(date2Str[1]-1),date2Str[2]);
            var t1 = date1Obj.getTime();
            var t2 = date2Obj.getTime();
            var dateTime = 1000*60*60*24; //每一天的毫秒数
            var minusDays = Math.floor(((t2-t1)/dateTime));//计算出两个日期的天数差
            var days = Math.abs(minusDays);//取绝对值
            return days;
         }


         function getNowFormatDate(date,addDayCount) {

	   		var now = new Date(date);
			now.setDate(now.getDate()+addDayCount);
			//格式化日，如果小于9，前面补0
			var day = ("0" + now.getDate()).slice(-2);
			var mday =  ("0" + now.getDate()).slice(-2);
			var month = ("0" + (now.getMonth() + 1)).slice(-2);
			//拼装完整日期格式
			var newDate = now.getFullYear()+"-"+(month)+"-"+(day) ;
			return newDate;

		}

		function getDate(){
	    var ddd = new Date();
		var day =ddd.getDate();

		if(ddd.getMonth()<10){
		var month = "0"+(ddd.getMonth()+1);
		}

		if(ddd.getDate()<10){
		 day = "0"+ddd.getDate();
		}

		var datew = ddd.getFullYear()+"-"+month+"-"+day;
		return datew;
	}
</script>
</html>
